package com.lmaos.allcontrol.beancontrol.paramInject_;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public abstract class InjectorTypeAbstract extends InjectorParamsAnnotation implements InjectorType{
	protected InjectorTypeHandler injectorTypeHandler;
	protected Map<Class, InjectorTypeHandler> injectorTypeHandlerCache = new ConcurrentHashMap<Class, InjectorTypeHandler>(64);

	@Override
	public void addInjectTypeHandler(Class type, InjectorTypeHandler injectorTypeHandler) {
		
		injectorTypeHandlerCache.put(type, injectorTypeHandler);
	}

	@Override
	public void setInjectTypeHandler(InjectorTypeHandler injectorTypeHandler) {
		this.injectorTypeHandler = injectorTypeHandler;
		
	}

	@Override
	public InjectorTypeHandler getInjectorTypeHandler(Class type) {
		InjectorTypeHandler injectorTypeHandler = injectorTypeHandlerCache.get(type);
		if(injectorTypeHandler == null){
			injectorTypeHandler = this.injectorTypeHandler;
		}
		return injectorTypeHandler;
	}

}

